#ifndef SERVO_H_
#define SERVO_H_

#include <slave.h>
#include <cassert>

class Servo: public Slave
{
public:
    Servo();
    ~Servo();

    bool Parse(EcXml &ecxml, ec_master_t* master, int index);

    /**
     * @Func
     *      SetPos
     * @Berif
     *      set target position
     * @Input
     *      targetpos: the position of targetpos
     * @Output
     *      none
     */
    void SetPos(int32_t targetPos);

    /**
     * @Func
     *      StatusTransite
     * @Berif
     *      slave status transite
     * @Input
     *      none
     * @Output
     *      none
     */
    bool StatusTransite();

    uint16_t SdoAccess(void);

    /**
     * @Func
     *      Retrieve
     * @Berif
     *      Read the feedback from the slave
     * @Input
     *      domainPtr: the ethercat frame of data domain
     * @Output
     *      none
     */
    void Retrieve(uint8_t* domainPtr);

    /**
     * @Func
     *      Publisher
     * @Berif
     *      Write data to be distributed to slave
     * @Input
     *      domainPtr: the ethercat frame of data domain
     * @Output
     *      none
     */
    void Publisher(uint8_t* domainPtr);

    uint16_t GetErrorCode() { return txpdo_.errcode; }
    int8_t GetState() { return status_; }

private:
    int8_t status_;
};

#endif
